package com.lsj.firsterp.controller;

import com.lsj.firsterp.core.AjaxResult;
import com.lsj.firsterp.model.User;
import com.lsj.firsterp.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author Lsj
 * @version 1.0
 * @date 2021/7/1 18:11
 */
@Controller
@AllArgsConstructor
public class LoginController {
    private final UserService userService;

    @RequestMapping("index")
    public String login(){
        return "login";
    }

    @PostMapping(value = "loginAfter")
    @ResponseBody
    public AjaxResult<String> loginAfter(User user){
        User user1 = userService.login(user);
        if(user1!=null){
            System.out.println("进入成功");
            return new AjaxResult<String>("请求成功");
        }else {
            System.out.println("进入失败");
            return new AjaxResult<String>(303,"请求失败");
        }
    }
    @RequestMapping("welcome")
    public String test(){
        return "welcome";
    }
}
